package com.hzlx.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzlx.bean.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PermissionDao extends BaseMapper<Permission> {
    @Select("select  * from sys_permission where perm_type = 0 order by id")
    List<Permission> findAllRoutes();
    @Select("select * from sys_permission where parent_id = #{parentId}")
    List<Permission> findByParentId(Integer parentId);
    String sql="select e.*" +
             " from sys_user u" +
            "   left join sys_user_role r on r.user_id = u.id" +
            "   left join sys_role o on o.id = r.role_id" +
            "   left join sys_role_permission m on m.role_id = o.id" +
            "   left join sys_permission e on e.id = m.permission_id" +
            "   left join sys_department d on d.id = u.department_id" +
            "   where account = #{account} order by e.id";
    @Select(sql)
    List<Permission> findAllRoutesByUser(String account);
}
